
#ifndef ___LOGGGER_ASYNC___
#define ___LOGGGER_ASYNC___

#include "Logger.h"
#include "Log.h"


namespace woe
{
	//
	//	an asynchronized implementation of logger interface
	//	not implement yet
	//
	class TUTIL_API LoggerAsync : public Logger
	{
	public:
		LoggerAsync();
		virtual ~LoggerAsync();

		//
		//	set current logger level
		//	log event that less than this level will be ignored
		//
		virtual void setLogLevel(short lvl);

		//
		//	do log an event, and the log message will be tagged with a log level and log label
		//
		virtual void log(short lvl, short label, const string& strMsg);

		//
		//	register targets, base on log level and labels
		//	
		//
		virtual void registerTarget(LogTarget* tgt, short lvl, short label);

	protected:
		short		current_logger_level_;

		struct TargetEntry
		{
			TargetEntry(const short& lvl = 0, const short& label = 0, LogTarget* tgt = NULL)
				:required_level_(lvl), required_label_(label), target_(tgt)
			{
			}

			bool meetRequirement(const short& lvl, const short& label)
			{
				return (lvl>=required_level_) && (label==LLB_ALL || required_label_==LLB_ALL || (label&required_label_)!=0 );
			}


			short required_level_;
			short required_label_;
			LogTarget*	target_;
		};

		typedef std::list<TargetEntry>	TargetEntryList;

		TargetEntryList		target_entrys_;
	};
}

#endif
